import Vue from 'vue'
import VueRouter from 'vue-router'

// 配置路由懒加载
const home = () => import('views/home/Home')
const goods = () => import('views/goods/Goods')
const cart = () => import('views/cart/Cart')
const profile = () => import('views/profile/Profile')

Vue.use(VueRouter)
const VueRouterReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace (to) {
  return VueRouterReplace.call(this, to).catch(err => err)
}

const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component: home
  },
  {
    path: '/goods',
    component: goods
  },
  {
    path: '/cart',
    component: cart
  },
  {
    path: '/profile',
    component: profile
  }
]
export default new VueRouter({
  routes
})
